﻿using System;

namespace PhoneNetTools.Dns
{
    /// <summary>
    /// An exception used for particular errors resulting from DNS requests/responses.
    /// </summary>
    public class DnsException : Exception
    {
        /// <summary>
        /// Gets or sets the error code.
        /// Set to <c>NoError</c> if this data was not available or the error is not related to a server response.
        /// </summary>
        public ResponseCode ErrorCode
        {
            get;
            set;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DnsException"/> class.
        /// </summary>
        public DnsException()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DnsException"/> class.
        /// </summary>
        /// <param name="message">The error message that explains the reason for the exception.</param>
        public DnsException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DnsException"/> class.
        /// </summary>
        /// <param name="message">The error message that explains the reason for the exception.</param>
        /// <param name="errorCode">The error code to use.</param>
        public DnsException(string message, ResponseCode errorCode)
            : base(message)
        {
            ErrorCode = errorCode;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DnsException"/> class.
        /// </summary>
        /// <param name="message">The error message that explains the reason for the exception.</param>
        /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
        public DnsException(string message, Exception innerException)
            : base(message, innerException)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DnsException"/> class.
        /// </summary>
        /// <param name="message">The error message that explains the reason for the exception.</param>
        /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
        /// <param name="errorCode">The error code to use.</param>
        public DnsException(string message, Exception innerException, ResponseCode errorCode)
            : base(message, innerException)
        {
            ErrorCode = errorCode;
        }
    }
}
